package special_tree;

import lexer.Token;
import tree.ClassScope;
import tree.IdentifierScope;
import tree.MethodScope;
import tree.MyTree;
import tree.NamingException;
import tree.ScopeRegistry;
import tree.Tree;

public class BlockTree extends MyTree {

	@Deprecated
	private IdentifierScope iS;
	@Deprecated
	private MethodScope mS;
	@Deprecated
	private ClassScope cS;
	
	public BlockTree(Token token, Tree... operands) {
		super(token, operands);
	}

	/* (non-Javadoc)
	 * @see tree.MyTree#preAnalyzeNames(tree.IdentifierScope, tree.MethodScope, tree.ClassScope)
	 */
	@Override
	@Deprecated
	public void preAnalyzeNames(IdentifierScope identScope,
			MethodScope methodScope, ClassScope classScope)
			throws NamingException {
		iS = identScope.pushScope();
		mS = methodScope.pushScope();
		cS = classScope.pushScope();
		if (this.getParent() instanceof ClassDeclTree) {
			ScopeRegistry.putMethodScope(this.getParent().getToken().toString(), mS);
		}
		super.preAnalyzeNames(iS, mS, cS);
	}

	/* (non-Javadoc)
	 * @see tree.MyTree#analyzeNames(tree.IdentifierScope, tree.MethodScope, tree.ClassScope)
	 */
	@Override
	@Deprecated
	public void analyzeNames(IdentifierScope identScope,
			MethodScope methodScope, ClassScope classScope)
			throws NamingException {
		if (this.getParent() instanceof ClassDeclTree) {
			ScopeRegistry.putIdentifierScope(this.getParent().getToken().toString(), iS);
		}
		super.analyzeNames(iS, mS, cS);
	}

	@Deprecated
	public IdentifierScope getIdentSubScope() {
		return iS;
	}
	
	@Deprecated
	public MethodScope getMethodSubScope() {
		return mS;
	}
	
	@Deprecated
	public ClassScope getClassSubScope() {
		return cS;
	}
}
